package com.example.equipmentmanage.utils

import androidx.lifecycle.MutableLiveData
import com.example.equipmentmanage.entity.SheBeiEntity
import com.example.equipmentmanage.entity.SheDetailEntity
import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.mvvm.Res
import dagger.hilt.android.lifecycle.HiltViewModel
import retrofit2.http.Body
import javax.inject.Inject
@HiltViewModel
class SheBeiViewModel @Inject constructor(private val repo:SheBeiRepo):BaseViewModel() {
    val SheBeiSuccess=MutableLiveData<SheBeiEntity>()

    fun SheBei(){
        httpRequest({repo.apiService.getSheBei()},{SheBeiSuccess.postValue(it)})
    }

    val SheDetailSuccess=MutableLiveData<SheDetailEntity>()

    fun SheDetail(id:Int){
        httpRequest({repo.apiService.getSheDetail(id)},{SheDetailSuccess.postValue(it)})
    }

    val SheAddSuccess=MutableLiveData<SheDetailEntity>()

    fun SheAdd(body: Any){
       httpRequest({repo.apiService.addSheBei(repo.mapTopBody(body))},{SheAddSuccess.postValue(it)})
    }

    val DelSheSuccess=MutableLiveData<Boolean>()

    fun SheDel(id: Int){
        httpRequest({repo.apiService.deleteSheBei(id)},{DelSheSuccess.postValue(it)})
    }


    val SheQuerySuccess=MutableLiveData<SheBeiEntity>()

    fun SheQuery(keyword: String){
        httpRequest({repo.apiService.querySheBei(keyword)},{SheQuerySuccess.postValue(it)})
    }
}